<template>
  <div>
	  <div>
      <div style="margin:2% 0;display: inline-block;">
        <span>名称：</span>
        <el-input style="width: 150px;" @keydown.enter.native="select" clearable placeholder="请输入名称" v-model="name"></el-input>
      </div>
	  </div>
	  <el-table
		v-loading="tableDataLoading"
	    :data="tableData.content"
		row-key="id">
      <el-table-column prop="nickName" label="名字"/>
      <el-table-column prop="badge" label="头像" width="120">
        <template slot-scope="scope">
          <div v-if="scope.row.headImg == '' || scope.row.headImg == null">
            <img src="~@/assets/img/avatar.png" alt="" width="60" height="60">
          </div>
          <div v-else>
            <img :src="scope.row.headImg" alt="" width="60" height="60">
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="gameType" label="游戏类型">
        <template slot-scope="scope">
          {{scope.row.gameType == 1? '王者': '吃鸡'}}
        </template>
      </el-table-column>
      <el-table-column prop="skill" label="擅长位置">
        <template slot-scope="scope">
          <span>{{scope.row.skill ? scope.row.skill : '未设置'}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="dan" label="段位"/>
      <el-table-column prop="area" label="区服">
        <template slot-scope="scope">
          <span>{{scope.row.area ? scope.row.area == 1? '微信': 'qq' : '未设置'}}</span>
        </template>
      </el-table-column>

      <el-table-column prop="status" label="封禁状态">
        <template slot-scope="scope">
          <el-tag
            :type="scope.row.state === 1 ? 'success' : 'info'"
            disable-transitions>{{scope.row.state == 1? '正常': '封禁'}}</el-tag>
        </template>
      </el-table-column>

      <el-table-column
        prop="createTime"
        label="创建时间">
      </el-table-column>
	    <el-table-column
	      label="操作"
        width="80px"
        align="center"
        fixed="right">
	      <template slot-scope="scope">
          <el-button style="margin-bottom: 5px" size="mini" type="primary" @click="toDetail(scope.row)">详情</el-button>
          <br>
<!--	        <el-button-->
<!--	          size="mini"-->
<!--	          type="danger"-->
<!--	          @click="deletes(scope.row)">删除-->
<!--	        </el-button>-->
	      </template>
	    </el-table-column>
	  </el-table>
	  <div style="text-align: center;margin-top: 10px;">
	    <el-pagination
	      @size-change="handleSizeChange"
	      @current-change="handleCurrentChange"
	      :page-sizes="[5, 10, 15, 20]"
	      :page-size="size"
	      :current-page="page"
	      layout="total,sizes, prev, pager, next"
	      :total="tableData.totalElements">
	    </el-pagination>
	  </div>
  </div>
</template>

<script>
  const level = [
    {
      label: '非常满意',
      value: 1
    },
    {
      label: '满意',
      value: 2
    },
    {
      label: '一般',
      value: 3
    },
    {
      label: '不满意',
      value: 4
    },
  ]
	export default {
	    data() {
	      return {
				size:5,
				page:1,
        name: null,
				tableDataLoading:false,
        tableData:{
          content: []
        },
			}
		},
    filters: {
      levelFormat(value){
        if(!value) return ''
        return level[value*1-1].label
      },
    },
		methods: {
      // select自动选择
      selectTrigger() {
        this.dataSelect()
      },
      // 查询
      select() {
        this.page = 1
        this.size = 5
        this.dataSelect()
      },
			handleSizeChange (val) {
			  this.size = val
			  this.dataSelect()
			},
			handleCurrentChange (val) {
			  this.page = val
			  this.dataSelect()
			},
      toDetail(row){
        this.$router.push({path: '/whereasDetail', query: {id: row.id}})
      },
			// 删除分类
			deletes(row){
				this.$confirm(`确定删除此条记录?`, '提示', {
				  confirmButtonText: '确定',
				  cancelButtonText: '取消',
				  type: 'warning'
				}).then(() => {
          this.$http({
            url: this.$http.adornUrl2('/team/delete'),
            method: 'get',
            params: this.$http.adornParams({
              'id':row.id
            })
          }).then(({data}) => {
            this.$message({
              message: '删除成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.dataSelect()
              }
            })
          })
        }).catch(() => {})
			},
      // 获取数据
      dataSelect () {
        let page = this.page - 1
        this.tableDataLoading = true
        this.$http({
          url: this.$http.adornUrl2('/whereas/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page':page,
            'size':this.size,
            'name':this.name,
            // 'userId':this.userId,
            // 'area':this.area,
          })
        }).then(({data}) => {
          this.tableDataLoading = false
          // console.log(data)
          this.tableData = data.data || {content: []};
        })
      }
		},
    mounted() {
      this.dataSelect()
    }
	  };
</script>

<style>

</style>
